/*
 * IMGr :: jQuery Image Rounder v1.0.1
 * http://steamdev.com/imgr
 *
 * Copyright 2010, SteamDev
 * Released under the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 *
 * Date: Wed October 20, 2010
 */
/*!
 * jQuery Migrate - v1.0.0 - 2013-01-14
 * https://github.com/jquery/jquery-migrate
 * Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors; Licensed MIT
 */
(function( jQuery, window, undefined ) {
"use strict";


var warnedAbout = {};

// List of warnings already given; public read only
jQuery.migrateWarnings = [];

// Set to true to prevent console output; migrateWarnings still maintained
// jQuery.migrateMute = false;

// Forget any warnings we've already given; public
jQuery.migrateReset = function() {
	warnedAbout = {};
	jQuery.migrateWarnings.length = 0;
};

function migrateWarn( msg) {
	if ( !warnedAbout[ msg ] ) {
		warnedAbout[ msg ] = true;
		jQuery.migrateWarnings.push( msg );
		if ( window.console && console.warn && !jQuery.migrateMute ) {
			console.warn( "JQMIGRATE: " + msg );
		}
	}
}

function migrateWarnProp( obj, prop, value, msg ) {
	if ( Object.defineProperty ) {
		// On ES5 browsers (non-oldIE), warn if the code tries to get prop;
		// allow property to be overwritten in case some other plugin wants it
		try {
			Object.defineProperty( obj, prop, {
				configurable: true,
				enumerable: true,
				get: function() {
					migrateWarn( msg );
					return value;
				},
				set: function( newValue ) {
					migrateWarn( msg );
					value = newValue;
				}
			});
			return;
		} catch( err ) {
			// IE8 is a dope about Object.defineProperty, can't warn there
		}
	}

	// Non-ES5 (or broken) browser; just set the property
	jQuery._definePropertyBroken = true;
	obj[ prop ] = value;
}

if ( document.compatMode === "BackCompat" ) {
	// jQuery has never supported or tested Quirks Mode
	migrateWarn( "jQuery is not compatible with Quirks Mode" );
}


var attrFn = {},
	attr = jQuery.attr,
	valueAttrGet = jQuery.attrHooks.value && jQuery.attrHooks.value.get ||
		function() { return null; },
	valueAttrSet = jQuery.attrHooks.value && jQuery.attrHooks.value.set ||
		function() { return undefined; },
	rnoType = /^(?:input|button)$/i,
	rnoAttrNodeType = /^[238]$/,
	rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
	ruseDefault = /^(?:checked|selected)$/i;

// jQuery.attrFn
migrateWarnProp( jQuery, "attrFn", attrFn, "jQuery.attrFn is deprecated" );

jQuery.attr = function( elem, name, value, pass ) {
	var lowerName = name.toLowerCase(),
		nType = elem && elem.nodeType;

	if ( pass ) {
		migrateWarn("jQuery.fn.attr( props, pass ) is deprecated");
		if ( elem && !rnoAttrNodeType.test( nType ) && jQuery.isFunction( jQuery.fn[ name ] ) ) {
			return jQuery( elem )[ name ]( value );
		}
	}

	// Warn if user tries to set `type` since it breaks on IE 6/7/8
	if ( name === "type" && value !== undefined && rnoType.test( elem.nodeName ) ) {
		migrateWarn("Can't change the 'type' of an input or button in IE 6/7/8");
	}

	// Restore boolHook for boolean property/attribute synchronization
	if ( !jQuery.attrHooks[ lowerName ] && rboolean.test( lowerName ) ) {
		jQuery.attrHooks[ lowerName ] = {
			get: function( elem, name ) {
				// Align boolean attributes with corresponding properties
				// Fall back to attribute presence where some booleans are not supported
				var attrNode,
					property = jQuery.prop( elem, name );
				return property === true || typeof property !== "boolean" &&
					( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?

					name.toLowerCase() :
					undefined;
			},
			set: function( elem, value, name ) {
				var propName;
				if ( value === false ) {
					// Remove boolean attributes when set to false
					jQuery.removeAttr( elem, name );
				} else {
					// value is true since we know at this point it's type boolean and not false
					// Set boolean attributes to the same name and set the DOM property
					propName = jQuery.propFix[ name ] || name;
					if ( propName in elem ) {
						// Only set the IDL specifically if it already exists on the element
						elem[ propName ] = true;
					}

					elem.setAttribute( name, name.toLowerCase() );
				}
				return name;
			}
		};

		// Warn only for attributes that can remain distinct from their properties post-1.9
		if ( ruseDefault.test( lowerName ) ) {
			migrateWarn( "jQuery.fn.attr(" + lowerName + ") may use property instead of attribute" );
		}
	}

	return attr.call( jQuery, elem, name, value );
};

// attrHooks: value
jQuery.attrHooks.value = {
	get: function( elem, name ) {
		var nodeName = ( elem.nodeName || "" ).toLowerCase();
		if ( nodeName === "button" ) {
			return valueAttrGet.apply( this, arguments );
		}
		if ( nodeName !== "input" && nodeName !== "option" ) {
			migrateWarn("property-based jQuery.fn.attr('value') is deprecated");
		}
		return name in elem ?
			elem.value :
			null;
	},
	set: function( elem, value ) {
		var nodeName = ( elem.nodeName || "" ).toLowerCase();
		if ( nodeName === "button" ) {
			return valueAttrSet.apply( this, arguments );
		}
		if ( nodeName !== "input" && nodeName !== "option" ) {
			migrateWarn("property-based jQuery.fn.attr('value', val) is deprecated");
		}
		// Does not return so that setAttribute is also used
		elem.value = value;
	}
};


var matched, browser,
	oldInit = jQuery.fn.init,
	// Note this does NOT include the # XSS fix from 1.7!
	rquickExpr = /^(?:.*(<[\w\W]+>)[^>]*|#([\w\-]*))$/;

// $(html) "looks like html" rule change
jQuery.fn.init = function( selector, context, rootjQuery ) {
	var match;

	if ( selector && typeof selector === "string" && !jQuery.isPlainObject( context ) &&
			(match = rquickExpr.exec( selector )) && match[1] ) {
		// This is an HTML string according to the "old" rules; is it still?
		if ( selector.charAt( 0 ) !== "<" ) {
			migrateWarn("$(html) HTML strings must start with '<' character");
		}
		// Now process using loose rules; let pre-1.8 play too
		if ( context && context.context ) {
			// jQuery object as context; parseHTML expects a DOM object
			context = context.context;
		}
		if ( jQuery.parseHTML ) {
			return oldInit.call( this, jQuery.parseHTML( jQuery.trim(selector), context, true ),
					context, rootjQuery );
		}
	}
	return oldInit.apply( this, arguments );
};
jQuery.fn.init.prototype = jQuery.fn;

jQuery.uaMatch = function( ua ) {
	ua = ua.toLowerCase();

	var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
		/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
		/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
		/(msie) ([\w.]+)/.exec( ua ) ||
		ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
		[];

	return {
		browser: match[ 1 ] || "",
		version: match[ 2 ] || "0"
	};
};

matched = jQuery.uaMatch( navigator.userAgent );
browser = {};

if ( matched.browser ) {
	browser[ matched.browser ] = true;
	browser.version = matched.version;
}

// Chrome is Webkit, but Webkit is also Safari.
if ( browser.chrome ) {
	browser.webkit = true;
} else if ( browser.webkit ) {
	browser.safari = true;
}

jQuery.browser = browser;

// Warn if the code tries to get jQuery.browser
migrateWarnProp( jQuery, "browser", browser, "jQuery.browser is deprecated" );

jQuery.sub = function() {
	function jQuerySub( selector, context ) {
		return new jQuerySub.fn.init( selector, context );
	}
	jQuery.extend( true, jQuerySub, this );
	jQuerySub.superclass = this;
	jQuerySub.fn = jQuerySub.prototype = this();
	jQuerySub.fn.constructor = jQuerySub;
	jQuerySub.sub = this.sub;
	jQuerySub.fn.init = function init( selector, context ) {
		if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
			context = jQuerySub( context );
		}

		return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
	};
	jQuerySub.fn.init.prototype = jQuerySub.fn;
	var rootjQuerySub = jQuerySub(document);
	migrateWarn( "jQuery.sub() is deprecated" );
	return jQuerySub;
};


var oldFnData = jQuery.fn.data;

jQuery.fn.data = function( name ) {
	var ret, evt,
		elem = this[0];

	// Handles 1.7 which has this behavior and 1.8 which doesn't
	if ( elem && name === "events" && arguments.length === 1 ) {
		ret = jQuery.data( elem, name );
		evt = jQuery._data( elem, name );
		if ( ( ret === undefined || ret === evt ) && evt !== undefined ) {
			migrateWarn("Use of jQuery.fn.data('events') is deprecated");
			return evt;
		}
	}
	return oldFnData.apply( this, arguments );
};


var rscriptType = /\/(java|ecma)script/i,
	oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack,
	oldFragment = jQuery.buildFragment;

jQuery.fn.andSelf = function() {
	migrateWarn("jQuery.fn.andSelf() replaced by jQuery.fn.addBack()");
	return oldSelf.apply( this, arguments );
};

// Since jQuery.clean is used internally on older versions, we only shim if it's missing
if ( !jQuery.clean ) {
	jQuery.clean = function( elems, context, fragment, scripts ) {
		// Set context per 1.8 logic
		context = context || document;
		context = !context.nodeType && context[0] || context;
		context = context.ownerDocument || context;

		migrateWarn("jQuery.clean() is deprecated");

		var i, elem, handleScript, jsTags,
			ret = [];

		jQuery.merge( ret, jQuery.buildFragment( elems, context ).childNodes );

		// Complex logic lifted directly from jQuery 1.8
		if ( fragment ) {
			// Special handling of each script element
			handleScript = function( elem ) {
				// Check if we consider it executable
				if ( !elem.type || rscriptType.test( elem.type ) ) {
					// Detach the script and store it in the scripts array (if provided) or the fragment
					// Return truthy to indicate that it has been handled
					return scripts ?
						scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) :
						fragment.appendChild( elem );
				}
			};

			for ( i = 0; (elem = ret[i]) != null; i++ ) {
				// Check if we're done after handling an executable script
				if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) {
					// Append to fragment and handle embedded scripts
					fragment.appendChild( elem );
					if ( typeof elem.getElementsByTagName !== "undefined" ) {
						// handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration
						jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript );

						// Splice the scripts into ret after their former ancestor and advance our index beyond them
						ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
						i += jsTags.length;
					}
				}
			}
		}

		return ret;
	};
}

jQuery.buildFragment = function( elems, context, scripts, selection ) {
	var ret,
		warning = "jQuery.buildFragment() is deprecated";

	// Set context per 1.8 logic
	context = context || document;
	context = !context.nodeType && context[0] || context;
	context = context.ownerDocument || context;

	try {
		ret = oldFragment.call( jQuery, elems, context, scripts, selection );

	// jQuery < 1.8 required arrayish context; jQuery 1.9 fails on it
	} catch( x ) {
		ret = oldFragment.call( jQuery, elems, context.nodeType ? [ context ] : context[ 0 ], scripts, selection );

		// Success from tweaking context means buildFragment was called by the user
		migrateWarn( warning );
	}

	// jQuery < 1.9 returned an object instead of the fragment itself
	if ( !ret.fragment ) {
		migrateWarnProp( ret, "fragment", ret, warning );
		migrateWarnProp( ret, "cacheable", false, warning );
	}

	return ret;
};

var eventAdd = jQuery.event.add,
	eventRemove = jQuery.event.remove,
	eventTrigger = jQuery.event.trigger,
	oldToggle = jQuery.fn.toggle,
	oldLive = jQuery.fn.live,
	oldDie = jQuery.fn.die,
	ajaxEvents = "ajaxStart|ajaxStop|ajaxSend|ajaxComplete|ajaxError|ajaxSuccess",
	rajaxEvent = new RegExp( "\\b(?:" + ajaxEvents + ")\\b" ),
	rhoverHack = /(?:^|\s)hover(\.\S+|)\b/,
	hoverHack = function( events ) {
		if ( typeof( events ) != "string" || jQuery.event.special.hover ) {
			return events;
		}
		if ( rhoverHack.test( events ) ) {
			migrateWarn("'hover' pseudo-event is deprecated, use 'mouseenter mouseleave'");
		}
		return events && events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
	};

// Event props removed in 1.9, put them back if needed; no practical way to warn them
if ( jQuery.event.props && jQuery.event.props[ 0 ] !== "attrChange" ) {
	jQuery.event.props.unshift( "attrChange", "attrName", "relatedNode", "srcElement" );
}

// Undocumented jQuery.event.handle was "deprecated" in jQuery 1.7
migrateWarnProp( jQuery.event, "handle", jQuery.event.dispatch, "jQuery.event.handle is undocumented and deprecated" );

// Support for 'hover' pseudo-event and ajax event warnings
jQuery.event.add = function( elem, types, handler, data, selector ){
	if ( elem !== document && rajaxEvent.test( types ) ) {
		migrateWarn( "AJAX events should be attached to document: " + types );
	}
	eventAdd.call( this, elem, hoverHack( types || "" ), handler, data, selector );
};
jQuery.event.remove = function( elem, types, handler, selector, mappedTypes ){
	eventRemove.call( this, elem, hoverHack( types ) || "", handler, selector, mappedTypes );
};

jQuery.fn.error = function() {
	var args = Array.prototype.slice.call( arguments, 0);
	migrateWarn("jQuery.fn.error() is deprecated");
	args.splice( 0, 0, "error" );
	if ( arguments.length ) {
		return this.bind.apply( this, args );
	}
	// error event should not bubble to window, although it does pre-1.7
	this.triggerHandler.apply( this, args );
	return this;
};

jQuery.fn.toggle = function( fn, fn2 ) {

	// Don't mess with animation or css toggles
	if ( !jQuery.isFunction( fn ) || !jQuery.isFunction( fn2 ) ) {
		return oldToggle.apply( this, arguments );
	}
	migrateWarn("jQuery.fn.toggle(handler, handler...) is deprecated");

	// Save reference to arguments for access in closure
	var args = arguments,
		guid = fn.guid || jQuery.guid++,
		i = 0,
		toggler = function( event ) {
			// Figure out which function to execute
			var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
			jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );

			// Make sure that clicks stop
			event.preventDefault();

			// and execute the function
			return args[ lastToggle ].apply( this, arguments ) || false;
		};

	// link all the functions, so any of them can unbind this click handler
	toggler.guid = guid;
	while ( i < args.length ) {
		args[ i++ ].guid = guid;
	}

	return this.click( toggler );
};

jQuery.fn.live = function( types, data, fn ) {
	migrateWarn("jQuery.fn.live() is deprecated");
	if ( oldLive ) {
		return oldLive.apply( this, arguments );
	}
	jQuery( this.context ).on( types, this.selector, data, fn );
	return this;
};

jQuery.fn.die = function( types, fn ) {
	migrateWarn("jQuery.fn.die() is deprecated");
	if ( oldDie ) {
		return oldDie.apply( this, arguments );
	}
	jQuery( this.context ).off( types, this.selector || "**", fn );
	return this;
};

// Turn global events into document-triggered events
jQuery.event.trigger = function( event, data, elem, onlyHandlers  ){
	if ( !elem & !rajaxEvent.test( event ) ) {
		migrateWarn( "Global events are undocumented and deprecated" );
	}
	return eventTrigger.call( this,  event, data, elem || document, onlyHandlers  );
};
jQuery.each( ajaxEvents.split("|"),
	function( _, name ) {
		jQuery.event.special[ name ] = {
			setup: function() {
				var elem = this;

				// The document needs no shimming; must be !== for oldIE
				if ( elem !== document ) {
					jQuery.event.add( document, name + "." + jQuery.guid, function() {
						jQuery.event.trigger( name, null, elem, true );
					});
					jQuery._data( this, name, jQuery.guid++ );
				}
				return false;
			},
			teardown: function() {
				if ( this !== document ) {
					jQuery.event.remove( document, name + "." + jQuery._data( this, name ) );
				}
				return false;
			}
		};
	}
);


})( jQuery, window );


(function($) {
	
	$.fn.imgr = function(settings) {
		
		var isWeb = $.browser.webkit;
		var isIE = $.browser.msie;
		var isIEOld = $.browser.msie && parseInt($.browser.version)<9;
		var isMoz = $.browser.mozilla;
		var isOp = $.browser.opera;
		
		var defaults = {
						radius:"10px",
						size:"0px",
						color:"#000",
						style:"solid"
						};
		
		if(settings){$.extend(defaults,settings);};
		
		defaults.style = defaults.style.toLowerCase();
		defaults.radius = defaults.radius.toString();
		defaults.size = parseInt(defaults.size)+"px";
		defaults.color = (colourNameToHex(defaults.color));
		if(defaults.color.indexOf('#')== -1){defaults.color = "#"+defaults.color;}
		
		var tl,tr,bl,br;
		var cor = (defaults.radius).split(" ");
		if(cor.length==1 || cor.length > 4){ tl = tr = bl = br = cor[0]; };
		if(cor.length==2){ tl = tr = cor[0]; bl = br = cor[1]; };
		if(cor.length==3){ tl = cor[0]; tr = cor[1]; bl = br = cor[2]; };
		if(cor.length==4){ tl = cor[0]; tr = cor[1]; br = cor[2]; bl = cor[3]; };
		tl=parseInt(tl);tr=parseInt(tr);bl=parseInt(bl);br=parseInt(br);
		

		var rad = tl+"px " + tr+"px " + br+"px " + bl+"px";
		
		return this.each(function(){
			var o = $(this);
			
			if(o[0].nodeName.toLowerCase()=="img"){
				
				var src = o.attr("src");
				var padt,padr,padb,padl,margt,margr,margb,margl,top,right,bottom,left,float,pos,offt,offr,offb,offl,_w,_h,_stroke,vDashStyle,vLineStyle;
				
				vDashStyle = "solid";
				vLineStyle = "single";
				if(defaults.style=="dotted"){vDashStyle="dot";}
				if(defaults.style=="dashed"){vDashStyle="dash";}
				if(defaults.style=="double"){vLineStyle="thinthin";}
				
				_w = parseInt(o.width());
				_h = parseInt(o.height());

				_stroke = parseInt(defaults.size);
				
				padt = parseInt(o.css('padding-top'));
				padr = parseInt(o.css('padding-right'));
				padb = parseInt(o.css('padding-bottom'));
				padl = parseInt(o.css('padding-left'));
				
				margt = o.css('margin-top'); margt = (margt=='auto')?0:parseInt(margt);
				margr = o.css('margin-right'); margr = (margr=='auto')?0:parseInt(margr);
				margb = o.css('margin-bottom'); margb = (margb=='auto')?0:parseInt(margb);
				margl = o.css('margin-left'); margl = (margl=='auto')?0:parseInt(margl);
				
				var posI = o.position();
				
				top = o.css('top');
				right = o.css('right');
				bottom = o.css('bottom');
				left = o.css('left');
				
				if(isOp){
				
					if(right!='auto'){
						if((parseInt(posI.left) + o.width()) == parseInt(right)){
							right="auto";	
						}
					}
					
					if(left!='auto'){
						if(parseInt(posI.left) == parseInt(left)){
							left="auto";	
						}
					}
					
					if(top!='auto'){
						if(parseInt(o[0].offsetTop) == parseInt(top)){
							top="auto";
						}
					}
					
					if(bottom!='auto'){
						if((parseInt(o[0].offsetTop) + o.height()) == parseInt(bottom)){
							bottom="auto";
						}
					}
				
				}

				float = o.css('float');
				pos = o.css('position');
				if (pos!="absolute"){pos="relative";}
				
				offt = (padt + margt)+"px ";
				offr = (padr + margr)+"px ";
				offb = (padb + margb)+"px ";
				offl = (padl + margl)+"px ";
				
				if(isIEOld){
					
					$(window).load(function(){	
											
						if(document.namespaces['v']==null) { 
							document.namespaces.add("v","urn:schemas-microsoft-com:vml");
							var vmlStyle = document.createStyleSheet();
							vmlStyle.addRule("v\\:shape","behavior: url(#default#VML);");
							vmlStyle.addRule("v\\:fill","behavior: url(#default#VML);");
							vmlStyle.addRule("v\\:stroke","behavior: url(#default#VML);");
						}
						
					});
					
					var _halfStroke = Math.round(_stroke/2);
					offt = (parseInt(offt)+_halfStroke)+"px ";
					offr = (parseInt(offr)+_halfStroke)+"px ";
					offb = (parseInt(offb)+_halfStroke)+"px ";
					offl = (parseInt(offl)+_halfStroke)+"px ";
					
					if(!o.parent().hasClass('imgr')){
						
						$(window).load(function(){
							
							var style = "display:inline-block;margin:"+offt + offr + offb + offl+";padding:0;top:"+top+";right:"+right+";bottom:"+bottom+";left:"+left+";float:"+float+";position:"+pos+";width:"+(_w+_stroke)+"px;height:"+(_h+_stroke)+"px;";
							o.css({'margin':'0','padding':'0','top':'0','right':'0','bottom':'0','left':'0','border':'0 none','float':'none'});
							o.wrap("<span class='imgr' style='"+style+"'></span>");	
							var shape = "<v:shape class='vml-shape' strokecolor='"+defaults.color+"' stroked='"+((_stroke==0)?'f':'t')+"' strokeweight='"+defaults.size+"' coordorigin='0 0' coordsize='"+((_stroke==0)?(_w-1)+' '+(_h-1):(_w-_stroke)+' '+(_h-_stroke))+"' style='width:"+_w+"px;height:"+_h+"px;position:absolute;' "
									+ "path='m "+tl+",0 l "+(_w-tr)+",0 qx "+_w+","+tr+" l "+_w+","+(_h-br)+" qy "+(_w-br)+","+_h+" l "+bl+","+_h+" qx 0,"+(_h-bl)+" l 0,"+tl+" qy "+tl+",0 e'>"
									+ "</v:shape>";
							var fill = "<v:fill class='vml-fill' src='"+src+"' type='frame' style='width:100%;height:100%;'></v:fill>";
							var bdrStyle = "<v:stroke dashstyle='"+vDashStyle+"' linestyle='"+vLineStyle+"' />";
							
							var obj = document.createElement(shape);
							obj.innerHTML = fill + bdrStyle;
							var par = o[0].parentNode;
							o.css({'position':'absolute','z-index':'1','opacity':'0'});
							if(o.parent()[0].nodeName.toLowerCase() == "a"){o.parent().css('cursor','pointer');}
							if(o.parent().parent()[0].nodeName.toLowerCase() == "a"){o.parent().parent().css('cursor','pointer');}
							if(o.parent().parent().parent()[0].nodeName.toLowerCase() == "a"){o.parent().parent().parent().css('cursor','pointer');}
							par.appendChild(obj);
							
							var cache = {
										width:_w,
										height:_h,
										stroke:_stroke,
										color:defaults.color,
										border:defaults.size,
										tl:tl,
										tr:tr,
										bl:bl,
										br:br,
										src:src,
										offt:offt,
										offl:offl,
										offb:offb,
										offr:offr,
										vDash:vDashStyle,
										vLine:vLineStyle
										};
										
							o.parent('.imgr').data("cache",cache);
						
						});
						
					} else {
						
						var data = o.parent('.imgr').data('cache');
						if(!settings.radius){
							tl = data.tl;
							tr = data.tr;
							bl = data.bl;
							br = data.br;
						}
						if(!settings.size){
							defaults.size = data.border;
							_stroke = data.stroke;
						}
						if(!settings.color){
							defaults.color = data.color;
						}
						if(!settings.style){
							vDashStyle = data.vDash;
							vLineStyle = data.vLine;
						}
						
						var shape = "<v:shape class='vml-shape' strokecolor='"+defaults.color+"' stroked='"+((_stroke==0)?'f':'t')+"' strokeweight='"+defaults.size+"' coordorigin='0 0' coordsize='"+((_stroke==0)?(data.width-1)+' '+(data.height-1):(data.width-_stroke)+' '+(data.height-_stroke))+"' style='width:"+data.width+"px;height:"+data.height+"px;position:absolute;' "
								+ "path='m "+tl+",0 l "+(data.width-tr)+",0 qx "+data.width+","+tr+" l "+data.width+","+(data.height-br)+" qy "+(data.width-br)+","+data.height+" l "+bl+","+data.height+" qx 0,"+(data.height-bl)+" l 0,"+tl+" qy "+tl+",0 e'>"
								+ "</v:shape>";
						var fill = "<v:fill class='vml-fill' src='"+src+"' type='frame' style='width:100%;height:100%;'></v:fill>";	
						var bdrStyle = "<v:stroke dashstyle='"+vDashStyle+"' linestyle='"+vLineStyle+"' />";
						
						var obj = document.createElement(shape);
						obj.innerHTML = fill + bdrStyle;
						var par = o[0].parentNode;
						o.css({'position':'absolute','z-index':'1','opacity':'0'});
						o.parent('.imgr').find('.vml-shape').remove();
						
						var _halfStroke = Math.round(_stroke/2);
						var _oldStroke = Math.round(data.stroke/2);
						
						offt = (parseInt(data.offt)-_oldStroke+_halfStroke)+"px ";
						offr = (parseInt(data.offr)-_oldStroke+_halfStroke)+"px ";
						offb = (parseInt(data.offb)-_oldStroke+_halfStroke)+"px ";
						offl = (parseInt(data.offl)-_oldStroke+_halfStroke)+"px ";
						
						o.parent('.imgr').css('margin',offt + offr + offb + offl).css('width',(data.width+_stroke)).css('height',(data.height+_stroke));
						
						if(o.parent()[0].nodeName.toLowerCase() == "a"){o.parent().css('cursor','pointer');}
						if(o.parent().parent()[0].nodeName.toLowerCase() == "a"){o.parent().parent().css('cursor','pointer');}
						if(o.parent().parent().parent()[0].nodeName.toLowerCase() == "a"){o.parent().parent().parent().css('cursor','pointer');}
						par.appendChild(obj);							

						var cache = {
									width:data.width,
									height:data.height,
									stroke:_stroke,
									color:defaults.color,
									border:defaults.size,
									tl:tl,
									tr:tr,
									bl:bl,
									br:br,
									src:src,
									offt:offt,
									offl:offl,
									offb:offb,
									offr:offr,
									vDash:vDashStyle,
									vLine:vLineStyle
									};
									
						o.parent('.imgr').data("cache",cache);							
						
					}
					
				} else {
					
					var style = "display:inline-block;border-radius:"+rad+";border-color:"+defaults.color+";border-style:"+defaults.style+";border-width:"+defaults.size+";background-repeat:no-repeat;background-origin:border-box;background-image:url("+src+");background-size:101% 101%;";
					style += "margin:"+offt + offr + offb + offl+";padding:0;top:"+top+";right:"+right+";bottom:"+bottom+";left:"+left+";float:"+float+";position:"+pos+";";
					
					if(isMoz){
						style += "-moz-border-radius:"+rad+";-moz-background-origin:border-box;-moz-background-size:101% 101%;";	
					}
					if(isWeb){
						
						if(typeof rad=="string"){rad = rad.split(" ");}
						style += "-webkit-border-top-left-radius:"+rad[0]+";-webkit-border-top-right-radius:"+rad[1]+";-webkit-border-bottom-right-radius:"+rad[2]+";-webkit-border-bottom-left-radius:"+rad[3]+";-webkit-background-origin:border-box;-webkit-background-size:101% 101%;";
					}
	
					
					if(!o.parent().hasClass('imgr')){
						o.css({'margin':'0','padding':'0','top':'0','right':'0','bottom':'0','left':'0','border':'0 none','float':'none'});
						o.wrap("<span class='imgr' style='"+style+"'></span>");				
					} else {
						var par = o.parent('.imgr');
												
						if(settings.radius){
							if(!isWeb){
								par.css('border-radius',rad);
							} else {
								par.css({"-webkit-border-top-left-radius":rad[0],"-webkit-border-top-right-radius":rad[1],"-webkit-border-bottom-right-radius":rad[2],"-webkit-border-bottom-left-radius":rad[3]});
							}
							if(isMoz){par.css('-moz-border-radius',rad);}

						}
						if(settings.size){par.css('border-width',defaults.size);}
						if(settings.color){par.css('border-color',defaults.color);}
						if(settings.style){par.css('border-style',defaults.style);}
					}
					
					o.css("opacity","0");
					
				}
			
			} // end if img
			
		}); // end each
		

		

	} // end imgr

})(jQuery);

function colourNameToHex(colour){
	
    var colours = {"aliceblue":"#f0f8ff","antiquewhite":"#faebd7","aqua":"#00ffff","aquamarine":"#7fffd4","azure":"#f0ffff",
    "beige":"#f5f5dc","bisque":"#ffe4c4","black":"#000000","blanchedalmond":"#ffebcd","blue":"#0000ff","blueviolet":"#8a2be2","brown":"#a52a2a","burlywood":"#deb887",
    "cadetblue":"#5f9ea0","chartreuse":"#7fff00","chocolate":"#d2691e","coral":"#ff7f50","cornflowerblue":"#6495ed","cornsilk":"#fff8dc","crimson":"#dc143c","cyan":"#00ffff",
    "darkblue":"#00008b","darkcyan":"#008b8b","darkgoldenrod":"#b8860b","darkgray":"#a9a9a9","darkgreen":"#006400","darkkhaki":"#bdb76b","darkmagenta":"#8b008b","darkolivegreen":"#556b2f",
    "darkorange":"#ff8c00","darkorchid":"#9932cc","darkred":"#8b0000","darksalmon":"#e9967a","darkseagreen":"#8fbc8f","darkslateblue":"#483d8b","darkslategray":"#2f4f4f","darkturquoise":"#00ced1",
    "darkviolet":"#9400d3","deeppink":"#ff1493","deepskyblue":"#00bfff","dimgray":"#696969","dodgerblue":"#1e90ff",
    "firebrick":"#b22222","floralwhite":"#fffaf0","forestgreen":"#228b22","fuchsia":"#ff00ff",
    "gainsboro":"#dcdcdc","ghostwhite":"#f8f8ff","gold":"#ffd700","goldenrod":"#daa520","gray":"#808080","green":"#008000","greenyellow":"#adff2f",
    "honeydew":"#f0fff0","hotpink":"#ff69b4",
    "indianred ":"#cd5c5c","indigo ":"#4b0082","ivory":"#fffff0","khaki":"#f0e68c",
    "lavender":"#e6e6fa","lavenderblush":"#fff0f5","lawngreen":"#7cfc00","lemonchiffon":"#fffacd","lightblue":"#add8e6","lightcoral":"#f08080","lightcyan":"#e0ffff","lightgoldenrodyellow":"#fafad2",
    "lightgrey":"#d3d3d3","lightgreen":"#90ee90","lightpink":"#ffb6c1","lightsalmon":"#ffa07a","lightseagreen":"#20b2aa","lightskyblue":"#87cefa","lightslategray":"#778899","lightsteelblue":"#b0c4de",
    "lightyellow":"#ffffe0","lime":"#00ff00","limegreen":"#32cd32","linen":"#faf0e6",
    "magenta":"#ff00ff","maroon":"#800000","mediumaquamarine":"#66cdaa","mediumblue":"#0000cd","mediumorchid":"#ba55d3","mediumpurple":"#9370d8","mediumseagreen":"#3cb371","mediumslateblue":"#7b68ee",
    "mediumspringgreen":"#00fa9a","mediumturquoise":"#48d1cc","mediumvioletred":"#c71585","midnightblue":"#191970","mintcream":"#f5fffa","mistyrose":"#ffe4e1","moccasin":"#ffe4b5",
    "navajowhite":"#ffdead","navy":"#000080",
    "oldlace":"#fdf5e6","olive":"#808000","olivedrab":"#6b8e23","orange":"#ffa500","orangered":"#ff4500","orchid":"#da70d6",
    "palegoldenrod":"#eee8aa","palegreen":"#98fb98","paleturquoise":"#afeeee","palevioletred":"#d87093","papayawhip":"#ffefd5","peachpuff":"#ffdab9","peru":"#cd853f","pink":"#ffc0cb","plum":"#dda0dd","powderblue":"#b0e0e6","purple":"#800080",
    "red":"#ff0000","rosybrown":"#bc8f8f","royalblue":"#4169e1",
    "saddlebrown":"#8b4513","salmon":"#fa8072","sandybrown":"#f4a460","seagreen":"#2e8b57","seashell":"#fff5ee","sienna":"#a0522d","silver":"#c0c0c0","skyblue":"#87ceeb","slateblue":"#6a5acd","slategray":"#708090","snow":"#fffafa","springgreen":"#00ff7f","steelblue":"#4682b4",
    "tan":"#d2b48c","teal":"#008080","thistle":"#d8bfd8","tomato":"#ff6347","turquoise":"#40e0d0",
    "violet":"#ee82ee",
    "wheat":"#f5deb3","white":"#ffffff","whitesmoke":"#f5f5f5",
    "yellow":"#ffff00","yellowgreen":"#9acd32"};

    if (typeof colours[colour.toLowerCase()] != 'undefined'){return colours[colour.toLowerCase()];} else {return colour;};
}



